#!/bin/bash
FILE=`mktemp`
# try to find wrong monitoring nodes
mysql -e "select server_oid, dc_name, monitoring_nodeid from hardware where dc_name = 'stack' and monitoring_nodeid != '41' and monitoring_export = '1' and server_oid != '1040131'\G" -h10.4.0.135 -uzabbix_client -p ConfigMaster > $FILE
# try to find that in another dc
mysql -e "select server_oid, dc_name, monitoring_nodeid from hardware where dc_name = 'rambler' and monitoring_nodeid != '11' and monitoring_export = '1'\G" -h10.4.0.135 -uzabbix_client -p ConfigMaster >> $FILE 
# try to find AK hosts without monitoring
mysql -e "select net_ipaddr, mode, autoonline, toolset, monitoring_export FROM hardware WHERE toolset = 'datad, autocontextd, syslog_sd, syslog_rd' and not monitoring_export and mode = 'Production' and autoonline\G" -h10.4.0.135 -uzabbix_client -p ConfigMaster >> $FILE
# try to find BAN hosts without monitoring
mysql -e "select net_ipaddr, mode, autoonline, toolset, monitoring_export FROM hardware WHERE toolset = 'banner2d, parse2d, miscd, externald, datad, bsyncs, syslog_sd, syslog_rd' and not monitoring_export and mode = 'Production' and autoonline\G" -h10.4.0.135 -uzabbix_client -p ConfigMaster >> $FILE
# shitting in da mailbox, if cho-cho
if [ -s $FILE ]; then
cat $FILE | mail -s "RiZN check: Bad hands detected!" "duty-shift@begun.ru, rizn@begun.ru" || echo "FAIL"
fi
rm $FILE

